<?php
/**
 * Created by PhpStorm.
 * User: baidu
 * Date: 17/8/5
 * Time: 下午4:37
 */
namespace app\api\controller\v1;

use think\Controller;
use app\common\lib\exception\ApiException;
use app\common\validate\UserValidate;
use  think\Request;

class Login extends Controller
{
    public function index()
    {
        $result = [
            "userInfo"=>[
                'id'=> '4291d7da9005377ec9aec4a71ea837f',
                'name'=> '天野远子',
                'username'=> 'admin',
                'password'=> '',
                'avatar'=> '/avatar2.jpg',
                'status'=> 1,
                'telephone'=> '',
                'lastLoginIp'=> '27.154.74.117',
                'lastLoginTime'=> 1534837621348,
                'creatorId'=> 'admin',
                'createTime'=> 1497160610259,
                'merchantCode'=> 'TLif2btpzg079h15bk',
                'deleted'=> 0,
                'roleId'=> 'admin',
                'role'=> []
            ]
        ];


        return show(config('code.success'), 'OK', $result, 200);
    }
    
    public function phoneLogin()
    {
        $data = request()->param();
		dump($data);
        $validate = new UserValidate;
        
        if (!$validate->scene('add')->check($data)) {
			return show(config('code.error'), 'error', $validate->getError(), 200);
        }else{
			return show(config('code.success'), 'OK', "登录成功", 200);
		}
    }
}
